#include "randomgeneration.h"

#include <stdint.h>

// Prime so that we don't increase the possibility of collisions.
// Below 2^32 so that it fits in an assembly immediate.
// Courtesy of https://bigprimes.org/
constexpr uint32_t GEN_PRIME_INCREMENTS[128] = {
    160991227,
    615539387,
    139136747,
    592239539,
    601739071,
    902536639,
    417154511,
    124190947,
    350912953,
    552641143,
    241378009,
    727499161,
    830516237,
    649011019,
    178611313,
    246703147,
    681578717,
    214214729,
    436204253,
    894551831,
    583947491,
    405597239,
    756903031,
    420604201,
    573091567,
    256130671,
    293534011,
    288459287,
    246163271,
    784985521,
    244309831,
    720509219,
    966247663,
    941308609,
    308378267,
    964233601,
    900380791,
    397141793,
    203736811,
    463344611,
    812539913,
    350951203,
    714560809,
    540672833,
    917769491,
    665142883,
    874347479,
    104109251,
    167094337,
    595121851,
    505402243,
    456329857,
    837176653,
    557156311,
    535625581,
    306945347,
    113711173,
    930534421,
    418964797,
    927153707,
    335061497,
    135281207,
    863089441,
    161170699,
    717435781,
    768130243,
    143771323,
    931336333,
    406714631,
    538466399,
    668025037,
    914876723,
    225796253,
    488110109,
    990546917,
    707788561,
    271585519,
    526449893,
    645957601,
    573353107,
    363797761,
    290497813,
    439056169,
    643558859,
    621947003,
    551631173,
    706016461,
    307384423,
    440811083,
    409993687,
    843007621,
    501398423,
    254167217,
    716556493,
    523653803,
    870121067,
    611279363,
    580165259,
    256989319,
    297345947,
    370609901,
    437890043,
    902598083,
    786612301,
    694017223,
    597535157,
    510932707,
    703493653,
    970994873,
    333253153,
    905605067,
    731025803,
    947551313,
    946634867,
    131220361,
    641029517,
    431232049,
    889467883,
    462209603,
    441869789,
    372557071,
    356736713,
    328743599,
    826525717,
    128742517,
    114189143,
    433464781,
    311592769
};

extern uint32_t getRandomGenerationAddend(uint64_t randomNumber) {
  constexpr int numElements = (sizeof(GEN_PRIME_INCREMENTS) / sizeof(uint32_t));
  static_assert(numElements == 128);
  return GEN_PRIME_INCREMENTS[randomNumber % numElements];
}
